#pragma once

#include <stdint.h>
#include <memory>
#include "ikcp.h"
#include <string>
#include "type.h"
#if defined(WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <WinSock2.h>
#else
#include <arpa/inet.h>
#include <time.h>
#include <arpa/inet.h>
#include <unistd.h>
// for linux GetTickCount()
inline unsigned long GetTickCount() {
	struct timespec ts;
	clock_gettime(CLOCK_MONOTONIC, &ts);
	return (ts.tv_sec * 1000 + ts.tv_nsec / 1000000);
}
#endif

namespace KCP {
	// Macros definition.
#define KCP_CONNECTION_TIMEOUT_TIME (10 * 1000) 

// Establish time.
#define KCP_CONNECTING_TIMEOUT_TIME (60 * 1000) 

// kcp max packet size:64k
#define KCP_PACKET_MAX_SIZE         (64 * 1024)

// create flag.
#define CREATE_CONV                 "kcp_create_connect_conv"
#define NEW_CONNECTION              "kcp_new_connection_in"

	class CConnection;

	// event net type enum.
	enum eEventType {
		eConnect = 0,
		eDisconnect,
		eRcvMsg,
	};
	const char* eventTypeStr(eEventType eventType);

	// proto deal format.
	typedef int (event_callback_t)(CConnection* conn, eEventType, const char* msg, int len);
}
